package edu.nf.project.webs.accountsAndPermissions;

import edu.nf.project.entitys.entity.accountsAndPermissions.convention.Permissions;
import edu.nf.project.services.accountsAndPermissions.PermissionsService;
import edu.nf.project.services.exception.derivedAnomalies.RolesException;
import edu.nf.project.services.response.BaseController;
import edu.nf.project.services.response.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 角色管理控制器
 */
@RestController
@RequestMapping("/api/permissions")

public class PermissionsController extends BaseController {
    @Autowired
    private PermissionsService permissionsService;

    /**
     * 获取全部角色信息
     */
    @GetMapping
    public ResultVO<List<Permissions>> getAllRoles() {
        try {
            List<Permissions> roles = permissionsService.getAll();
            return success(roles);
        } catch (Exception e) {
            throw new RolesException(20000, "获取权限列表失败");
        }
    }
}
